<?php
include_once(NUKE_BASE_DIR.'header.php');
include_once("modules/".$module_name."/menu.php");
OpenTable();
global $userinfo;
$canupload = 0;
if ($userinfo['user_id'] != 1) {
	$username = $userinfo['username'];
    $usergroup = $db->sql_query("SELECT * FROM " . $prefix . "_bbuser_group WHERE user_id='".$userinfo['user_id']."'");
	while($usergroupcheck = $db->sql_fetchrow($usergroup))
    {
		$user_allowed = $db->sql_ufetchrow("SELECT group_single_user, img_allow FROM ".$prefix."_bbgroups WHERE group_id='".$usergroupcheck['group_id']."'");  
        if($user_allowed['group_single_user'] == 0 && $user_allowed['img_allow'] == 1)
        {
            $canupload = $user_allowed['img_allow'];
        }
    }
}
if($canupload != 1)
{
    echo _NOTALLOWED;
}
else{ 
include_once("modules/".$module_name."/admin/classes/Pagination.php");
$page = 1;
// how many records per page
$size = $config['max_show_image'];
// we get the current page from $_GET
if (isset($_GET['page'])){
    $page = (int) $_GET['page'];
}
$total_records = $db->sql_numrows($db->sql_query("SELECT * FROM `". $prefix ."_upload` WHERE username='".$username."'"));
// create the pagination class
$pagination = new Pagination();
$pagination->setLink("modules.php?name=Upload&op=yourimages&amp;page=%s");
$pagination->setPage($page);
$pagination->setSize($size);
$pagination->setTotalRecords($total_records);

	$result1 = $db->sql_query("SELECT * FROM `". $prefix ."_upload` WHERE username='".$username."'" . $pagination->getLimitSql()); 
	$url=$config['domain']."/".$config['path'];
	$widthimage = $config['maxwidth'];
	$heightimage = $config['maxheight'];
	$picturecount = 1;
	$maxcols = $config['maxcolumns'];
	echo"<p align=\"center\">";
	echo _WELCOME." ".$username."<br />"._HAVEUPLOADED." <b>".$total_records."</b> "._OFTHE." <b>".$config['maxuploads']."</b> "._ALLOWEDIMAGES."</p><br /><br />";
	echo"<table width=\"100%\" align=\"center\" cellpadding=\"15\" cellspacing=\"15\" border=\"0\">
	<tr>";
		while ($site_row = $db->sql_fetchrow($result1))
		{
				$afbeelding = $config['path'].$site_row['img'];
				list($width, $height, $type, $attr) = getimagesize($afbeelding);
				$img = $site_row['img'];
				$uniquecode= $site_row['uniquecode'];
				$tr = "";
			    if ( $picturecount % $maxcols == 0 ) {    // insert new row at every {$maxcols}th image
			        $tr = "
			        </tr>
			        <tr>";
			    }
				echo"
					<td align=\"center\" valign=\"top\">";
					if($widthimage <= $width || $heightimage <= $height){
						echo"<img width=\"".$widthimage."\" height=\"".$heightimage."\" src=\"".$url.$site_row['img']."\" border=\"0\" alt=\"\"/><br /> <b>[RESIZED]</b>";
					}else
					{
						echo"<img src=\"".$url.$site_row['img']."\" border=\"0\" alt=\"\"/>";
					}
				echo"<br /><br />
					"._DIRECTLINK.":&nbsp;&nbsp;&nbsp;<input type=\"text\" name=\"image\" value=\"".$url.$site_row['img']."\" onFocus=\"this.select()\"/>
						<span id=\"copyclipboard\" style=\"width:16px; height:16px;\">
							<object width=\"16\" height=\"16\">
								<PARAM NAME=FlashVars VALUE=\"txtToCopy=".$url.$site_row['img']."\">
								<param name=\"movie\" value=\"modules/".$module_name."/copyButton.swf\">
								<embed title=\""._DIRECTLINKTITLE."\" src=\"modules/".$module_name."/copyButton.swf\" wmode=\"transparent\" flashvars=\"txtToCopy=".$url.$site_row['img']."\" width=\"16\" height=\"16\">
								</embed>
							</object>
						</span>	
					<br /><br />
					"._IMGBBCODE.": <input type=\"text\" name=\"image\" value=\"[img]".$url.$site_row['img']."[/img]\" onFocus=\"this.select()\"/>
					<span id=\"copyclipboard\" style=\"width:16px; height:16px;\">
							<object width=\"16\" height=\"16\">
								<PARAM NAME=FlashVars VALUE=\"txtToCopy=[img]".$url.$site_row['img']."[/img]\">
								<param name=\"movie\" value=\"modules/".$module_name."/copyButton.swf\">
								<embed title=\""._IMGBBCODETITLE."\" src=\"modules/".$module_name."/copyButton.swf\" wmode=\"transparent\" flashvars=\"txtToCopy=[img]".$url.$site_row['img']."[/img]\" width=\"16\" height=\"16\">
								</embed>
							</object>
						</span>
					<br /><br />";
					$htmllink = '&lt;a href=&quot;'.$url.$img.'&quot; target=&quot;_blank&quot;&gt;&lt;img src=&quot;'.$url.$img.'&quot; border=&quot;0&quot; alt=&quot;&quot;&gt;&lt;/a&gt;';
					echo _HTMLCODE.": &nbsp;&nbsp;<input type='text' name='image' value='".$htmllink."' onFocus=\"this.select()\"/>
					<span id=\"copyclipboard\" style=\"width:16px; height:16px;\">
							<object width=\"16\" height=\"16\">
								<PARAM NAME=FlashVars VALUE=\"txtToCopy=".$htmllink."\">
								<param name=\"movie\" value=\"modules/".$module_name."/copyButton.swf\">
								<embed title=\""._HTMLCODETITLE."\" src=\"modules/".$module_name."/copyButton.swf\" wmode=\"transparent\" flashvars=\"txtToCopy=".$htmllink."\" width=\"16\" height=\"16\">
								</embed>
							</object>
						</span>
						<br />
						<br />
						<a href=\"modules.php?name=Upload&op=confirm_delete&uniquecode=$uniquecode\"><img src=\"modules/".$module_name."/display/delete.png\" border=\"0\" alt=\"Delete image\" title=\"delete image\" /></a>
					</td>
				" .$tr;
				$picturecount++;
		}//end of while lus (while fetch row)
	echo "</tr></table>";
echo"<div id=\"pagination\">";
$navigation = $pagination->create_links();
echo $navigation."</div>"; // will draw our page navigation
}//end of else (if allow == false)
CloseTable();
include_once(NUKE_BASE_DIR.'footer.php');
?>